
#ifndef _MEMBER_BWIDGET_H_
#define _MEMBER_BWIDGET_H_

#include <BIcon>
#include <BEvent>
#include <BRect>
#include <BFont>
#include <BCursor>
#include <BLayout>
#include <BStyle>
#include <BSizePolicy>
#include <BPixmap>

#include <BWidget>
#include "IWindow.h"
#include "IPaint.h"
#include "IRound.h"

#define widget_member(widget)		((member_BWidget*)((BWidget*)widget)->_ptr)

namespace BWE
{
	class member_BWidget
	{
	public:
		member_BWidget(BWidget* widget);
		~member_BWidget();

		bool ignored() const;
		void freshEnabled(bool enabled);

		void frame();
		void drawWidget(BWidget* widget, const BRect& clip, const BPoint& offset, int frameHeight);

		void syncWindowPos(const BPoint& wpos);
		void syncWindowSize(const BSize& wsize);

		bool procEvent(const BEvent& event);

		void dispenseStyles(BEvent& event);
		void applyStyle();
		void applyRoundStyle();

		void dirtyPixmaps();
		void freshRects();
		void freshRoundPoints();
		void freshLayoutPerch();
		void adjustDirtyLayouts();

		void dirtyLayout();
		void dirtyUpperLayout();

	public:
		BWidget*				boss;
		IWindowHolder			window;
		BPixmap*				pixmap;
		BHolder<IRound>			round;
		BEvent					paintEvent;
		BRect					absoluteRect;
		BRect					globalRect;
		BWidget*				parent;
		BArray<BWidgetHolder>	children;

		IState					state;
		bool					refresh;
		bool					dirty;
		bool					fbo_resized;
		GLuint					fbo;
		GLuint					rbo_depth;
		GLuint					tbo;
		BByte					transparency;
		bool					layered;

		BString					title;
		BHolder<BIcon>			titleIcon;
		BString					tips;
		bool					frameless;
		bool					visible;
		bool					modal;
		bool					floating;
		bool					droppable;
		bool					focusable;
		bool					focused;
		BHolder<BCursor>		cursor;

		BPoint					pos;
		BSize					size;
		BSize					minSize;
		BSize					maxSize;
		BSize					fixedSize;
		BSizePolicy				sizePolicy;

		BLayout*				upperLayout;
		BArray<BLayoutHolder>	layouts;

		bool					dirtyStyle;
		BHolder<BStyle>			realStyle;
		BHolder<BStyle>			style;
		BString					styleSheet;

		int						border;
		BPerch					perch;
		BMargin					margin;

		bool					resized;
		BRect					rectTitle;
		BRect					rectLeft;
		BRect					rectTop;
		BRect					rectRight;
		BRect					rectBottom;
		BRect					rectCenter;

	};
}

#endif
